<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>全文搜索技术深度解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .content-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            transition: all 0.3s ease;
        }
        
        .content-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 24px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .highlight-box {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
            padding: 2px 8px;
            border-radius: 4px;
            display: inline-block;
            font-weight: 500;
        }
        
        .tech-badge {
            background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
            color: white;
            padding: 4px 12px;
            border-radius: 20px;
            display: inline-block;
            font-size: 0.875rem;
            font-weight: 500;
            margin: 2px;
        }
        
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            padding: 20px;
            border-radius: 8px;
            overflow-x: auto;
            font-family: 'Consolas', 'Monaco', monospace;
            position: relative;
        }
        
        .code-block::before {
            content: attr(data-lang);
            position: absolute;
            top: 8px;
            right: 12px;
            font-size: 0.75rem;
            color: #888;
            text-transform: uppercase;
        }
        
        .mermaid {
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
        }
        
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 3rem;
            padding-right: 8px;
            margin-top: -4px;
            font-weight: 700;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-family: 'Noto Serif SC', serif;
        }
        
        .feature-icon {
            width: 60px;
            height: 60px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 16px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 1.5rem;
            margin-bottom: 1rem;
        }
        
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .animate-fade-in {
            animation: fadeInUp 0.6s ease-out;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto text-center animate-fade-in">
            <h1 class="text-5xl md:text-6xl font-bold mb-6" style="font-family: 'Noto Serif SC', serif;">
                全文搜索技术深度解析
            </h1>
            <p class="text-xl md:text-2xl mb-8 opacity-90">
                从 Lucene 到 Elasticsearch，构建高性能搜索引擎的完整指南
            </p>
            <div class="flex flex-wrap justify-center gap-4">
                <span class="tech-badge"><i class="fas fa-search mr-2"></i>全文检索</span>
                <span class="tech-badge"><i class="fas fa-database mr-2"></i>倒排索引</span>
                <span class="tech-badge"><i class="fas fa-network-wired mr-2"></i>分布式架构</span>
                <span class="tech-badge"><i class="fas fa-chart-line mr-2"></i>性能优化</span>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="max-w-6xl mx-auto px-6 py-12">
        
        <!-- Introduction -->
        <div class="content-card rounded-xl shadow-xl p-8 mb-8">
            <h2 class="section-title text-3xl font-bold mb-6 text-gray-800">
                <i class="fas fa-rocket text-purple-600 mr-3"></i>引言：全文搜索的技术挑战与应用场景
            </h2>
            <p class="text-lg leading-relaxed text-gray-700 mb-4">
                <span class="drop-cap">在</span>信息爆炸的时代，无论是电商平台的商品检索、社交网络的内容筛选，还是企业内部的文档管理，用户对高效、准确的全文搜索需求愈发明显。传统的关系型数据库虽然支持基于索引的精确查询，但在处理模糊匹配、多条件组合、语义分析等复杂场景时，效率往往不尽人意。
            </p>
            <p class="text-lg leading-relaxed text-gray-700">
                全文搜索引擎应运而生，旨在通过先进的索引结构和查询算法，快速定位目标信息，提升搜索性能和用户体验。本文将深入探讨全文搜索的核心技术，从基础概念到实战应用，为您呈现构建高性能搜索引擎的完整画卷。
            </p>
        </div>

        <!-- Core Concepts -->
        <div class="content-card rounded-xl shadow-xl p-8 mb-8">
            <h2 class="section-title text-3xl font-bold mb-6 text-gray-800">
                <i class="fas fa-lightbulb text-purple-600 mr-3"></i>全文搜索的核心概念
            </h2>
            
            <div class="grid md:grid-cols-3 gap-6 mb-8">
                <div class="bg-gradient-to-br from-purple-50 to-pink-50 p-6 rounded-lg">
                    <div class="feature-icon">
                        <i class="fas fa-layer-group"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3 text-gray-800">索引结构</h3>
                    <p class="text-gray-700">倒排索引是搜索引擎的心脏，通过词项到文档的映射实现快速检索</p>
                </div>
                
                <div class="bg-gradient-to-br from-blue-50 to-cyan-50 p-6 rounded-lg">
                    <div class="feature-icon" style="background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);">
                        <i class="fas fa-cut"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3 text-gray-800">分词技术</h3>
                    <p class="text-gray-700">将文本拆分为词元，是语义分析的基础，直接影响搜索准确性</p>
                </div>
                
                <div class="bg-gradient-to-br from-green-50 to-teal-50 p-6 rounded-lg">
                    <div class="feature-icon" style="background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);">
                        <i class="fas fa-sort-amount-up"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3 text-gray-800">评分机制</h3>
                    <p class="text-gray-700">通过TF-IDF、BM25等算法计算相关性，实现结果的智能排序</p>
                </div>
            </div>

            <!-- Inverted Index Visualization -->
            <div class="bg-gray-50 p-6 rounded-lg mb-6">
                <h4 class="text-lg font-bold mb-4 text-gray-800">
                    <i class="fas fa-diagram-project mr-2 text-purple-600"></i>倒排索引结构示意
                </h4>
                <div class="mermaid">
                    graph LR
                        A[文档集合] --> B[分词处理]
                        B --> C[词项提取]
                        C --> D[倒排索引]
                        D --> E["Java → [文档1, 文档2]"]
                        D --> F["搜索 → [文档1, 文档3]"]
                        D --> G["高性能 → [文档2]"]
                        style A fill:#f9f,stroke:#333,stroke-width:2px
                        style D fill:#bbf,stroke:#333,stroke-width:2px
                </div>
            </div>
        </div>

        <!-- Technical Architecture -->
        <div class="content-card rounded-xl shadow-xl p-8 mb-8">
            <h2 class="section-title text-3xl font-bold mb-6 text-gray-800">
                <i class="fas fa-cogs text-purple-600 mr-3"></i>技术选型与框架解析
            </h2>
            
            <!-- Lucene Section -->
            <div class="mb-8">
                <h3 class="text-2xl font-bold mb-4 text-gray-800">
                    <span class="highlight-box">Lucene</span> 全文搜索的奠基石
                </h3>
                <p class="text-lg leading-relaxed text-gray-700 mb-4">
                    Apache Lucene 是一个高性能、功能完整的全文搜索引擎库，为众多搜索应用提供了核心能力。其模块化设计使得开发者能够灵活构建定制化的搜索解决方案。
                </p>
                
                <div class="grid md:grid-cols-2 gap-6 mb-6">
                    <div class="bg-purple-50 p-6 rounded-lg">
                        <h4 class="font-bold text-lg mb-3 text-purple-800">
                            <i class="fas fa-hammer mr-2"></i>索引构建流程
                        </h4>
                        <ol class="space-y-2 text-gray-700">
                            <li><i class="fas fa-folder-open text-purple-600 mr-2"></i>初始化索引目录</li>
                            <li><i class="fas fa-file-alt text-purple-600 mr-2"></i>文档分词与字段处理</li>
                            <li><i class="fas fa-save text-purple-600 mr-2"></i>通过 IndexWriter 写入索引</li>
                            <li><i class="fas fa-compress text-purple-600 mr-2"></i>索引优化与段合并</li>
                        </ol>
                    </div>
                    
                    <div class="bg-blue-50 p-6 rounded-lg">
                        <h4 class="font-bold text-lg mb-3 text-blue-800">
                            <i class="fas fa-search mr-2"></i>查询执行流程
                        </h4>
                        <ol class="space-y-2 text-gray-700">
                            <li><i class="fas fa-code text-blue-600 mr-2"></i>解析查询语句</li>
                            <li><i class="fas fa-filter text-blue-600 mr-2"></i>构建查询对象</li>
                            <li><i class="fas fa-bolt text-blue-600 mr-2"></i>执行索引搜索</li>
                            <li><i class="fas fa-list-ol text-blue-600 mr-2"></i>返回排序结果</li>
                        </ol>
                    </div>
                </div>
            </div>
            
            <!-- Elasticsearch Section -->
            <div>
                <h3 class="text-2xl font-bold mb-4 text-gray-800">
                    <span class="highlight-box" style="background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);">Elasticsearch</span> 分布式搜索的领军者
                </h3>
                <p class="text-lg leading-relaxed text-gray-700 mb-4">
                    基于 Lucene 构建的 Elasticsearch 提供了分布式、高可用的搜索能力，通过 RESTful API 和自动化的集群管理，极大简化了大规模搜索系统的构